package edu_xy.hm_02.slice;

import edu_xy.hm_02.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
/*
    * 页面由两部分构成
    * 页面布局代码   xml
    * 后台逻辑代码   java

*/

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 所关联的页面布局代码  xml
        super.setUIContent(ResourceTable.Layout_ability_main);
        // 获取页面中的按钮对象
        Button button_01=(Button)this.findComponentById(ResourceTable.Id_button_01);
        // 设置按钮中的单击事件
        button_01.setClickedListener(this::clickedListenerButton01);

        Button button_02=(Button)this.findComponentById(ResourceTable.Id_button_02);
        // 设置按钮中的单击事件
        button_02.setClickedListener(this::clickedListenerButton02);

        Button button_03=(Button)this.findComponentById(ResourceTable.Id_button_03);
        // 设置按钮中的单击事件
        button_03.setClickedListener(this::clickedListenerButton03);

        Button button_04=(Button)this.findComponentById(ResourceTable.Id_button_04);
        // 设置按钮中的单击事件
        button_04.setClickedListener(this::clickedListenerButton04);

        Button button_05=(Button)this.findComponentById(ResourceTable.Id_button_05);
        // 设置按钮中的单击事件
        button_05.setClickedListener(this::clickedListenerButton05);
    }

    private void clickedListenerButton05(Component component) {
        Intent intent = new Intent();
        // 实现跳转
        this.present(new MainAbilitySlice05(),intent);
    }

    private void clickedListenerButton04(Component component) {
        Intent intent = new Intent();
        // 实现跳转
        this.present(new MainAbilitySlice04(),intent);
    }

    private void clickedListenerButton03(Component component) {
        Intent intent = new Intent();
        // 实现跳转
        this.present(new MainAbilitySlice03(),intent);
    }

    private void clickedListenerButton02(Component component) {
        Intent intent = new Intent();
        // 实现跳转
        this.present(new MainAbilitySlice02(),intent);
    }
    // 跳转到第一个页面
    private void clickedListenerButton01(Component component) {
        // 创建意图
        Intent intent = new Intent();
        // 实现跳转
        this.present(new MainAbilitySlice01(),intent);
    }



    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
